package data_structure.mooc;

public class LinearSearch {

    private LinearSearch() {

    }

    /**
     * linear search ,remember to override "equal()" to adjust different circumstances
     * @param array
     * @param target
     * @param <E>
     * @return the index of target,return -1 if not found
     */
    public static <E> int search(E array[],E target){

        for(int i=0;i < array.length; i++){
            if(array[i].equals (target)){
                return i;
            }
        }
        return -1;
    }
}
